package ar.edu.utn.frsf.tpae.a2012.g02.dao.implementacion;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import ar.edu.utn.frsf.tpae.a2012.g02.dao.ClienteDAO;
import ar.edu.utn.frsf.tpae.a2012.g02.models.Cliente;

public class ClienteHibernateDAO extends GenericHibernateDAO<Cliente> implements
		ClienteDAO {

	private SessionFactory sessionFactory = new AnnotationConfiguration()
			.configure().buildSessionFactory();

	@Override
	public Cliente getByDni(String dni) {
		Session session = sessionFactory.openSession();
		Query query = session.createQuery("from " + Cliente.class.getName()
				+ " where dni = :dni");
		query.setString("dni", dni);
		return (Cliente) query.uniqueResult();
	}
}
